<?php
require_once 'php-sdk/facebook.php' ;
require_once 'php-sdk/base_facebook.php' ;
require_once "gameAPI.php";
//connect_fb();
//$user = "100000861563120";//to be replaced by /me

//$user_id = facebook_api_call("/me?fields=id,name");
//$friendlist = get_friend_list($user_id["id"]);

//$factory_id = get_factory($user_id["id"]);

//$user_id = facebook_api_call("/".$user."?fields=id,name");
//initialize();
$user_id = get_user_id();

$factory_id = get_factory_id($user_id);
$supervisors = get_certain_workers($factory_id, 'Supervisor');
$office_workers = get_certain_workers($factory_id, 'Office worker');
$production_workers = get_certain_workers($factory_id, 'Production line worker');

echo "<script language='javascript'> var supervisors = new Array(); var office_workers = new Array(); var production_workers = new Array(); var i=0;";

foreach($supervisors as $sv)
	echo "supervisors[i] = " . $sv . "; i++;";
echo "i=0;";
foreach ($office_workers as $ow)
	echo "office_workers[i] = " . $ow ."; i++;";
echo "i=0;";
foreach ($production_workers as $pw)
	echo "production_workers[i] = " . $pw ."; i++;";
echo "</script>";



$level_id_1 = get_level_id($factory_id, 1);
$level_id_2 = get_level_id($factory_id, 2);
$level_id_3 = get_level_id($factory_id, 3);

?>


<html>
<head>
<script src="js/jquery.js">
</script>
<script src="js/paginator.js">
</script>
<style type="text/css">
body {
  background: url("images/Status/hire_page.jpg") no-repeat;
}
.friendlist{
  position: absolute;
  font-family:"Arial";
  top: 130px;
  left: 60px;
  width: 200px;
  height: 700px;
  overflow: auto;
}
.supervisor{
  position: absolute;
  top: 190px;
  left: 287px;
  width: 500px;
  height: 125px;
}
.production{
  position: absolute;
  top: 570px;
  left: 287px;
  width: 500px;
  height: 125px;
}
.office{
  position: absolute;
  top: 380px;
  left: 287px;
  width: 500px;
  height: 125px;
}
.bottom_buttons{
  position: absolute;
  top: 690px;
  left: 277px;
  width: 510px;
  height: 125px;
}
.top_buttons{
  position: absolute;
  top: 10px;
  left: 267px;
  width: 200px;
  height: 100px;
}
.paginator{
  position: absolute;
  top: 700px;
  left: 80px;
  width: 200px;
  height: 200px;
}
.search
{
	position: absolute;
	top:80px;
	left:30px;
	width: 200px;
	height: 200px;
}

			#SupervisorProgressBar {
				height: 25px;
				width: 300px;
				position: absolute;
				left: 307px;
			 	top: 170px;
				border-style:solid;
				border-width:1px;
				border-color:#536680;
				border-radius:5px;
				-moz-border-radius:5px; /* Firefox 3.6 and earlier */
				background: url("images/Status/Calculate.png") no-repeat;
				background-position:center; 
			}
			#OfficeWorkerProgressBar {
				height: 25px;
				width: 300px;
				position: absolute;
				left: 307px;
				top: 360px;
				border-style:solid;
				border-width:1px;
				border-color:#536680;
				border-radius:5px;
				-moz-border-radius:5px; /* Firefox 3.6 and earlier */
				background: url("images/Status/Calculate.png") no-repeat;
				background-position:center; 
			}
			#ProductionWorkerProgressBar {
				height: 25px;
				width: 300px;
				position: absolute;
				left: 307px;
				top: 550px;
				border-style:solid;
				border-width:1px;
				border-color:#536680;
				border-radius:5px;
				-moz-border-radius:5px; /* Firefox 3.6 and earlier */
				background: url("images/Status/Calculate.png") no-repeat;
				background-position:center; 
			}
			
			#SupervisorProgressBarLast {
				height: 25px;
				width: 0px;
				position: absolute;
				left: 307px;
			 	top: 170px;
				background-color: #2B3E58;
				border-style:solid;
				border-width:1px;
				border-color:#2B3E58;
				border-radius:5px;
				-moz-border-radius:5px; /* Firefox 3.6 and earlier */
			}
			#OfficeWorkerProgressBarLast {
				height: 25px;
				width: 0px;
				position: absolute;
				left: 307px;
				top: 360px;
				background-color: #2B3E58;
				border-style:solid;
				border-width:1px;
				border-color:#2B3E58;
				border-radius:5px;
				-moz-border-radius:5px; /* Firefox 3.6 and earlier */
			}
			#ProductionWorkerProgressBarLast {
				height: 25px;
				width: 0px;
				position: absolute;
				left: 307px;
				top: 550px;
				background-color: #2B3E58;
				border-style:solid;
				border-width:1px;
				border-color:#2B3E58;
				border-radius:5px;
				-moz-border-radius:5px; /* Firefox 3.6 and earlier */
			}
			#SupervisorProgressBarCurr {
				height: 25px;
				width: 0px;
				position: absolute;
				left: 307px;
			 	top: 170px;
				background-color: #3f526c;
				border-style:solid;
				border-width:1px;
				border-color:#3f526c;
				border-radius:5px;
				-moz-border-radius:5px; /* Firefox 3.6 and earlier */
			}
			#OfficeWorkerProgressBarCurr {
				height: 25px;
				width: 0px;
				position: absolute;
				left: 307px;
				top: 360px;
				background-color: #3f526c;
				border-style:solid;
				border-width:1px;
				border-color:#3f526c;
				border-radius:5px;
				-moz-border-radius:5px; /* Firefox 3.6 and earlier */
			}
			#ProductionWorkerProgressBarCurr {
				height: 25px;
				width: 0px;
				position: absolute;
				left: 307px;
				top: 550px;
				background-color: #3f526c;
				border-style:solid;
				border-width:1px;
				border-color:#3f526c;
				border-radius:5px;
				-moz-border-radius:5px; /* Firefox 3.6 and earlier */
			}
			
#CashText {
			height:40px;
			width:140px;
			top:700px;
			left:630px;
			text-align:left;
			vertical-align:bottom;
			font-size:40px;
			font-family:"Lucida Console","Courier", serif;
			color:#8A5A3D;
			position:absolute;
		}

</style>
<script language="javascript">

var free = new Array();
free["supervisor"] = <?php echo $free_slots["Supervisor"] ?>;
free["office"] = <?php echo $free_slots["Office worker"] ?>;
free["production"] = <?php echo $free_slots["Production line worker"] ?>;

var friendlist = new Array();

FB.api(
  {
    method: 'fql.query',
    query: 'SELECT uid, name, profile_url FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name ASC'
  },
  function(response) {
	
    for (var i=0;i<response.length;i++)
	{
		friendlist[i] = response[i];
	}
	generate_candidate_list(friendlist);
  }
);

function generate_candidate_list(response)
{
	var string = "";
	for (var i = 0; i < response.length; i++)
	{
		if (jQuery.inArray(parseInt(response[i]['uid']), supervisors)==-1 && jQuery.inArray(parseInt(response[i]['uid']), office_workers)==-1 && jQuery.inArray(parseInt(response[i]['uid']), production_workers)==-1)
		{
			string = string + "<p><img src='https://graph.facebook.com/"+response[i]['uid']+"/picture' /><a href='"+response[i]['profile_url']+"'>"+response[i]['name']+"</a>";
			string = string + "<form><select id = 'jobtype_"+response[i]['uid']+ "' name='jobtype_"+response[i]['uid']+ "' onchange='AddToFactory(this.form.jobtype_"+response[i]['uid']+")'>";
			string = string + "<option value='pleaseselect'>Please Select</option>";
			if (free['supervisor'] != 0)
			{
				string = string + "<option value='supervisor'>Supervisor</option>";
			}
			if (free['office'] != 0)
			{
				string = string +  "<option value='office'>Office worker</option>";
			}
			if (free['production'] != 0)
			{
				string = string + "<option value='production'>Production worker</option>";
			}
			string = string + "</select></form></p>";
		}
	}
	$("#friends").html(string);
	$(function(){ $("#friends").pagination(); }); 
}

function AddToFactory(dropdown)
{
	var myindex  = dropdown.selectedIndex;
    var SelValue = dropdown.options[myindex].value;
	var user_id = dropdown.name.substring(8);
	var y = document.getElementById(user_id);
	if (y)
		RemoveFromFactory("cross_"+user_id);
	var x = document.getElementById(SelValue);
	$(x).fadeOut(600, function() {
		x.src = "https://graph.facebook.com/"+user_id+"/picture";
		x.id = user_id;
	});
	$(x).fadeIn(600);
	
	var cross = document.getElementById(SelValue+"_cross");
	cross.id = "cross_" + user_id;
	
	x.name = SelValue;
	free[SelValue]--;
	if (free[SelValue]==0)
	{
		var d1 = document.getElementsByTagName('select');
		for (var i=0; i< d1.length; i++)
		{
			for(var j=0;j<d1[i].options.length;j++)
			{
				if (d1[i].options[j].value == SelValue)
					d1[i].remove(j);
			}
		}
	}
}

function RemoveFromFactory(type)
{
	var x = document.getElementById(type.substring(6));
	
	if (x)
	{
		$(x).fadeOut(600, function() {
			x.src = "http://107.20.229.155/sqwtest/images/blank_profile_picture_small.jpg";
			x.id = x.name;
		});
		$(x).fadeIn(600);
		
		var cross = document.getElementById(type);
		cross.id = x.name + "_cross";
	
		var y = document.getElementById('jobtype_'+type.substring(6).toString());
		y.selectedIndex = 0;
	
		var previous = free[x.name];
		free[x.name]++;
		if (previous == 0 && free[x.name] == 1)
		{
			if (x.name=='production')
			{
				text = "Production worker";
			}
			else if (x.name=='office')
			{
				text = "Office worker";
			}
			else if (x.name=='supervisor')
			{
				text = "Supervisor";
			}
			
			var d1 = document.getElementsByTagName('select');
			
			for (var i=0; i<d1.length; i++)
			{
				//d1[i].options[index] = new Option(text, x.name);
				d1[i].options.add(new Option(text, x.name));
			}
		}
	}
	else
	{
		//var string = "gameAPI.php?func=remove_friend_from_factory&factory_id=<?php echo $factory_id ?>&worker_id="+type.substring(6);
		var answer = confirm("Are you sure you want to remove your friend from the factory?");
		if (answer)
		{
			
			if (window.XMLHttpRequest)
			{// code for IE7+, Firefox, Chrome, Opera, Safari
			  xmlhttp=new XMLHttpRequest();
			}
			else
			{// code for IE6, IE5
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
					alert("Worker removed from factory");
					var x = document.getElementsByName(type.substring(6));
					var previous_id = x[0].id;
					x[0].id = previous_id.substring(7);
					x[0].src = "http://107.20.229.155/sqwtest/images/blank_profile_picture_small.jpg";
					var cross = document.getElementById(previous_id + "_cross");
					cross.id = x[0].id + "_cross";
					
					//var y = document.getElementById('jobtype_'+type.substring(6).toString());
					//y.selectedIndex = 0;
					
				
					var previous = free[x[0].id];
					free[x[0].id]++;
					if (previous == 0 && free[x[0].id] == 1)
					{
						if (x[0].id=='production')
						{
							text = "Production worker";
						}
						else if (x[0].id=='office')
						{
							text = "Office worker";
						}
						else if (x[0].id=='supervisor')
						{
							text = "Supervisor";
						}
						
						var d1 = document.getElementsByTagName('select');
						
						for (var i=0; i<d1.length; i++)
						{
							//d1[i].options[index] = new Option(text, x.name);
							d1[i].options.add(new Option(text, x[0].id));
						}
					}
					free[x[0].id]++;
					if (x[0].id == 'production')
					{
						removeByElement(production_workers, type.substring(6));
					}
					else if (x[0].id == 'office')
					{
						removeByElement(office_workers, type.substring(6));
					}
					else if (x[0].id == 'supervisor')
					{
						removeByElement(supervisors, type.substring(6));
					}
					generate_candidate_list(friendlist);
				}
			}
			xmlhttp.open("GET","gameAPI.php?func=remove_friend_from_factory&factory_id=<?php echo $factory_id ?>&worker_id="+type.substring(6),true);
			xmlhttp.send();
		}
	}
}

function removeByElement(arrayName,arrayElement)
 {
  for(var i=0; i<arrayName.length;i++ )
   { 
  if(arrayName[i]==arrayElement)
  arrayName.splice(i,1); 
  } 
  }

function CancelAllSelections()
{
	var dropdowns = document.getElementsByTagName('select');

	for(var i=0; i<dropdowns.length; i++)
	{
		if(dropdowns[i].selectedIndex!=0)
		{
			var user_id = dropdowns[i].name.substring(8);
			RemoveFromFactory(user_id);
		}
	}
}

function strpos (haystack, needle) {
var i = (' ' + haystack + '').indexOf(needle,  0);
    return i === -1 ? false : i;
}

function showResult(str)
{
	if (str.length==0)
	{ 
		generate_candidate_list(friendlist);
	}
	else
	{
		var string = "";
		var string1 = str.toString().toLowerCase();
		var list = new Array();

		for (var i = 0; i<friendlist.length;i++)
		{
			var string2 = friendlist[i]['name'].toLowerCase();
			if (strpos(string2, string1))
			{
				list.push(friendlist[i]);
			}
		}
		generate_candidate_list(list);
	}

}

function inArray(needle, haystack) {
    var length = haystack.length;
    for(var i = 0; i < length; i++) {
        if(haystack[i] == needle) return true;
    }
    return false;
}

function ConfirmSelection()
{
	var allPictures = document.getElementsByTagName('img');
	var notNew = ["supervisor","alreadysupervisor","supervisor_cross", "alreadysupervisor_cross", "production","alreadyproduction","production_cross", "alreadyproduction_cross", "office","alreadyoffice", "office_cross", "alreadyoffice_cross", "submitselection"];
	var allNewStaff = '';
	
	for(var i=0; i<allPictures.length;i++)
	{
		if (allPictures[i].id!='' && !inArray(allPictures[i].id, notNew) && allPictures[i].id.substring(0,6) != 'cross_')
		{
			allNewStaff = allNewStaff + allPictures[i].id + "=" + allPictures[i].name + "&";
		}
	}
	
	alert(string);
	var string = "gameAPI.php?func=insert_friends_into_factory&factory_id=<?php echo $factory_id ?>&"+allNewStaff;
	var answer = confirm("Are you sure you want to add the selected into your factory?");
	if (answer)
		window.location.href=string;

}

			//var supervisor_progress_bar_last = null;
			//var office_worker_progress_bar_last = null;
			//var production_worker_progress_bar_last = null;
			//var supervisor_progress_bar_curr = null;
			//var office_worker_progress_bar_curr = null;
			//var production_worker_progress_bar_curr = null;
			
			var supervisor_progress_bar_last_progress = null;
			var office_worker_progress_bar_last_progress = null;
			var production_worker_progress_bar_last_progress = null;
			var supervisor_progress_bar_curr_progress = null;
			var office_worker_progress_bar_curr_progress = null;
			var production_worker_progress_bar_curr_progress = null;
			
			var t = null;

			function ShowProgressBar()
			{
				$("#SupervisorProgressBar").fadeOut('slow');
				$("#OfficeWorkerProgressBar").fadeOut('slow');
				$("#ProductionWorkerProgressBar").fadeOut('slow');
				if (! CheckEnd())
				{
					clearTimeout(t);
				}
				else
				{
					if (parseInt($("#SupervisorProgressBarLast").css('width')) < parseInt(supervisor_progress_bar_last_progress))
					{
						$("#SupervisorProgressBarLast").css('width','+=10');
					}
					if (parseInt($("#OfficeWorkerProgressBarLast").css('width')) < parseInt(office_worker_progress_bar_last_progress))
					{
						$("#OfficeWorkerProgressBarLast").css('width','+=10');
					}
					if (parseInt($("#ProductionWorkerProgressBarLast").css('width')) < parseInt(production_worker_progress_bar_last_progress))
					{
						$("#ProductionWorkerProgressBarLast").css('width','+=10');
					}
					if (parseInt($("#SupervisorProgressBarCurr").css('width')) < parseInt(supervisor_progress_bar_curr_progress))
					{
						$("#SupervisorProgressBarCurr").css('width','+=10');
					}
					if (parseInt($("#OfficeWorkerProgressBarCurr").css('width')) < parseInt(office_worker_progress_bar_curr_progress))
					{
						$("#OfficeWorkerProgressBarCurr").css('width','+=10');
					}
					if (parseInt($("#ProductionWorkerProgressBarCurr").css('width')) < parseInt(production_worker_progress_bar_curr_progress))
					{
						$("#ProductionWorkerProgressBarCurr").css('width','+=10');
					}
					t = setTimeout(ShowProgressBar, 100);
				}
			}
			
			function CheckEnd()
			{
				return (parseInt($("#SupervisorProgressBarLast").css('width')) < parseInt(supervisor_progress_bar_last_progress))
					|| (parseInt($("#OfficeWorkerProgressBarLast").css('width')) < parseInt(office_worker_progress_bar_last_progress))
					|| (parseInt($("#ProductionWorkerProgressBarLast").css('width')) < parseInt(production_worker_progress_bar_last_progress))
					|| (parseInt($("#SupervisorProgressBarCurr").css('width')) < parseInt(supervisor_progress_bar_curr_progress))
					|| (parseInt($("#OfficeWorkerProgressBarCurr").css('width')) < parseInt(office_worker_progress_bar_curr_progress))
					|| (parseInt($("#ProductionWorkerProgressBarCurr").css('width')) < parseInt(production_worker_progress_bar_curr_progress));
			}
			
			function init()
			{
				//supervisor_progress_bar_last = document.getElementById('SupervisorProgressBarLast');
				//office_worker_progress_bar_last = document.getElementById('OfficeWorkerProgressBarLast');
				//production_worker_progress_bar_last = document.getElementById('ProductionWorkerProgressBarLast');
				//supervisor_progress_bar_curr = document.getElementById('SupervisorProgressBarCurr');
				//office_worker_progress_bar_curr = document.getElementById('OfficeWorkerProgressBarCurr');
				//production_worker_progress_bar_curr = document.getElementById('ProductionWorkerProgressBarCurr');
				
				supervisor_progress_bar_last_progress = "<?php echo get_last_progress ($factory_id, 1)/get_max_exp ($level_id_1, 1)*300 . "px" ?>";
				office_worker_progress_bar_last_progress = "<?php echo get_last_progress($factory_id, 3)/get_max_exp ($level_id_3, 3)*300 . "px" ?>";
				production_worker_progress_bar_last_progress = "<?php echo get_last_progress ($factory_id, 2)/get_max_exp ($level_id_2, 2)*300 . "px" ?>";
				supervisor_progress_bar_curr_progress = "<?php echo get_curr_progress ($factory_id, 1)/get_max_exp ($level_id_1, 1)*300 . "px" ?>";
				office_worker_progress_bar_curr_progress = "<?php echo get_curr_progress ($factory_id, 3)/get_max_exp ($level_id_3, 3)*300 . "px" ?>";
				production_worker_progress_bar_curr_progress = "<?php echo get_curr_progress ($factory_id, 2)/get_max_exp ($level_id_2, 2)*300 . "px" ?>";
				
				$("#SupervisorProgressBarLast").css('width','0px');
				$("#OfficeWorkerProgressBarLast").css('width','0px');
				$("#ProductionWorkerProgressBarLast").css('width','0px');
				$("#SupervisorProgressBarCurr").css('width','0px');
				$("#OfficeWorkerProgressBarCurr").css('width','0px');
				$("#ProductionWorkerProgressBarCurr").css('width','0px');
				
				ShowProgressBar();
			}

			window.onload = init;
			
			function cashIn() {
			<?php echo update_progress($user_id); ?>
			<?php echo check_achievement($user_id); ?>
			}

</script>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25431105-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script> 
</head>
<body>

<div class="search">
<form>
<input type="text" size="30" name="friendname" value="Search for friend" onkeyup="showResult(value)" />
</form>
</div>

<div id="friends" class="friendlist"></div>

<div class="top_buttons">
<table cellspacing="20"><tr><td>
<img src="images/Status/Factory.png" onMouseDown="this.src='images/Status/Factory_click.png'; window.location.href='factory.php';" onMouseOver="this.src='images/Status/Factory_over.png';" onMouseOut="this.src='images/Status/Factory.png';" onMouseUp="this.src='images/Status/Factory_over.png';" />
</td>
<td>
<img src="images/Status/upgrade_.png" onMouseDown="this.src='images/Status/upgrade_click.png'; window.location.href='buy.php' ;" onMouseOver="this.src='images/Status/upgrade_over.png';" onMouseOut="this.src='images/Status/upgrade_.png';" onMouseUp="this.src='images/Status/upgrade_over.png';" />
</td>
<td>
<img src="images/Status/HELP.png" onMouseDown="this.src='images/Status/HELP_click.png'; window.location.href='help.php' ;" onMouseOver="this.src='images/Status/HELP_over.png';" onMouseOut="this.src='images/Status/HELP.png';" onMouseUp="this.src='images/Status/HELP_over.png';" />
</td>
</tr></table>
</div>


<div class="bottom_buttons">
<table cellspacing="10"><tr><td>
<img id="submitselection" src="images/Status/Hire.png" onMouseDown="this.src='images/Status/Hire_click.png'; ConfirmSelection();" onMouseOver="this.src='images/Status/Hire_over.png';" onMouseOut="this.src='images/Status/Hire.png';" onMouseUp="this.src='images/Status/Hire_over.png';"/>
</td>
<td>
<img src="images/Status/cashin_.png" onMouseDown="this.src='images/Status/cashin_click.png'; cashIn(); window.location.href='play.php';" onMouseOver="this.src='images/Status/cashin_over.png';" onMouseOut="this.src='images/Status/cashin_.png';" onMouseUp="this.src='images/Status/cashin_over.png';" />
</td></tr></table>
</div>


<div id = "SupervisorProgressBar"></div>
<div id = "SupervisorProgressBarCurr"></div>
<div id = "SupervisorProgressBarLast"></div>
<div class="supervisor">
<table cellspacing="20"><tr>
<?php foreach($supervisors as $supervisor) : ?>
<td><?php if ($supervisor == -1): ?>
	<img id="supervisor" src="http://107.20.229.155/sqwtest/images/blank_profile_picture_small.jpg"/>
	<img id="supervisor_cross" src="images/Status/cross_.png" onMouseDown="this.src='images/Status/cross_click.png'; RemoveFromFactory(this.id)" onMouseUp="this.src='images/Status/cross_over.png';" onMouseOver="this.src='images/Status/cross_over.png';" onMouseOut="this.src='images/Status/cross_.png';" />
	<?php else: ?>
	<img id="alreadysupervisor" name=<?php echo $supervisor ?> src="https://graph.facebook.com/<?php echo $supervisor ?>/picture"/>
	<img id="alreadysupervisor_cross" src="images/Status/cross_.png" onMouseDown="this.src='images/Status/cross_click.png'; RemoveFromFactory('cross_<?php echo $supervisor ?>')" onMouseUp="this.src='images/Status/cross_over.png';" onMouseOver="this.src='images/Status/cross_over.png';" onMouseOut="this.src='images/Status/cross_.png';" />
	<?php endif ?>
</td>
<?php endforeach; ?>
</tr></table>
</div>

<div id = "OfficeWorkerProgressBar"></div>
<div id = "OfficeWorkerProgressBarCurr"></div>
<div id = "OfficeWorkerProgressBarLast"></div>
<div class="office">
<table cellspacing="20"><tr>
<?php foreach($office_workers as $ow) : ?>
<td><?php if ($ow == -1): ?>
	<img id="office" src="http://107.20.229.155/sqwtest/images/blank_profile_picture_small.jpg"/>
	<img id="office_cross" src="images/Status/cross_.png" onMouseDown="this.src='images/Status/cross_click.png'; RemoveFromFactory(this.id)" onMouseUp="this.src='images/Status/cross_over.png';" onMouseOver="this.src='images/Status/cross_over.png';" onMouseOut="this.src='images/Status/cross_.png';"  />
	<?php else: ?>
	<img id="alreadyoffice" name=<?php echo $ow ?> src="https://graph.facebook.com/<?php echo $ow ?>/picture"/>
	<img id="alreadyoffice_cross" src="images/Status/cross_.png" onMouseDown="this.src='images/Status/cross_click.png'; RemoveFromFactory('cross_<?php echo $ow ?>')" onMouseUp="this.src='images/Status/cross_over.png';" onMouseOver="this.src='images/Status/cross_over.png';" onMouseOut="this.src='images/Status/cross_.png';" />
	<?php endif ?>
</td>
<?php endforeach; ?>
</tr></table>
</div>


<div id = "ProductionWorkerProgressBar"></div>
<div id = "ProductionWorkerProgressBarCurr"></div>
<div id = "ProductionWorkerProgressBarLast"></div>
<div class="production">
<table cellspacing="20"><tr>
<?php foreach($production_workers as $pw) : ?>
<td><?php if ($pw == -1): ?>
	<img id="production" src="http://107.20.229.155/sqwtest/images/blank_profile_picture_small.jpg"/>
	<img id="production_cross" src="images/Status/cross_.png" onMouseDown="this.src='images/Status/cross_click.png'; RemoveFromFactory(this.id)" onMouseUp="this.src='images/Status/cross_over.png';" onMouseOver="this.src='images/Status/cross_over.png';" onMouseOut="this.src='images/Status/cross_.png';"  />
	<?php else: ?>
	<img id="alreadyproduction" name=<?php echo $pw ?> src="https://graph.facebook.com/<?php echo $pw ?>/picture"/>
	<img id="alreadyproduction_cross" src="images/Status/cross_.png" onMouseDown="this.src='images/Status/cross_click.png'; RemoveFromFactory('cross_<?php echo $pw ?>')" onMouseUp="this.src='images/Status/cross_over.png';" onMouseOver="this.src='images/Status/cross_over.png';" onMouseOut="this.src='images/Status/cross_.png';" />
	<?php endif ?>
</td>
<?php endforeach; ?>
</tr></table>
</div>

<div id="CashText"><?php echo get_credit($user_id); ?></div>

</body>
</html>